package com.jine.boot6.suer.service.impl;

import com.jine.boot6.suer.mapper.SUserMapper;
import com.jine.boot6.suer.model.SUser;
import com.jine.boot6.suer.service.SUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SUserServiceImpl implements SUserService {

    @Autowired
    private SUserMapper sUserMapper;

    @Override
    public List<SUser> listUser() {
        return this.sUserMapper.selectById(null);
    }

    @Override
    public void saveUser(SUser user) {
        this.sUserMapper.insert(user);
    }

    @Override
    public SUser findUser(String id) {
        List<SUser> list  = this.sUserMapper.selectById(id);
        if(list!=null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public void deleteUser(String id) {
        this.sUserMapper.deleteById(id);
    }

    @Override
    public void updateUser(SUser user) {
        this.sUserMapper.updateUserById(user);
    }
}
